package com.mijie.query;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import m.secury.callbackItfs;
import net.sf.json.JSONArray;

import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.apache.tools.ant.taskdefs.ExecuteWatchdog;
import org.apache.tools.ant.taskdefs.Sleep;

import com.mijie.fentsi.exportTopic;
import com.mijie.fentsi.fentsiCa22;
import com.mijie.fentsi.fentsiOr;
import com.mijie.fentsi.renvaEventC;
import com.mijie.homi.search.util.DbNdsController;
import com.mijie.homi.search.util.Dbcontroller;
import com.mijie.homi.search.util.fileC0;
import com.mijie.homi.search.util.god;
import com.mijie.homi.search.util.listUtil;
import com.mijie.homi.search.util.securyInt;
import com.mijie.homi.search.util.timeTester;
import com.mijie.indexall.indexAllCls;


public class fulltxtCtrlMultiThrd extends fulltxtControllor implements
		Runnable {

	fulltxtCtrlMultiThrd() {
		super(5);
	}

	static ExecutorService es = Executors.newFixedThreadPool(2);
	private Map curLine;
	/**
	 * words arr format
	 */
	private List<String> CurLIne_fentsi;
	private Connection conn;
	private int indexNum;
	protected static boolean threadPoosIsComplete = false;
	
	public static BlockingQueue<String> Sqlqueue = new LinkedBlockingQueue<String>();
	public static Date start = new Date();

	/**
	 * 
	 // for (int i = 0; i < 500; i++) { // // // // es.execute(new Runnable()
	 * { // // // // @Override // // public void run() { // //
	 * System.out.println("aa"); // // try { // // Thread.sleep(7000); // // }
	 * catch (InterruptedException e) { // // // // e.printStackTrace(); // // }
	 * // // // // } // // // // } // // ); // }
	 * 
	 * @param args
	 * @throws Exception
	 */
	@SuppressWarnings("static-access")
	public static void main(String[] args) {

		try {
			 // Thread.sleep(15000);

		} catch (Exception e) {

			e.printStackTrace();
		}

		timeTester t = new timeTester(" cb1");
		fulltxtCtrlMultiThrd c = new fulltxtCtrlMultiThrd();
		fulltxtCtrlMultiThrd.mood4fullTable = "mood4full";
		// c.indexBatchID =god.getUUid();
	//	c.indexBatchID = "cb30";
		if (args.length > 0) {
			int n = Integer.parseInt(args[0].trim());
			c.indexNum = n; 
		}
// String indexBatchID=securyInt.getString(args,1);
// if(indexBatchID.length()==0)
//	 c.indexBatchID=god.getUUid_MMdd_HHmmss(); 
// else
	 	 c.indexBatchID=args[1].trim();
		
		
		c.indexAll();

		// while(true){
		// try {
		// Thread.sleep(2000);
		// } catch (InterruptedException e) {
		//				 
		// e.printStackTrace();
		// }
		// // if(Sqlqueue.size()==0)
		// dbc4sql_queue_thread.commit();
		// t.printUseTime();
		// if(1==2)
		// break;
		//			
		// }
		logger.info("------all time" + t.pasttime);
		t.printUseTime();

	}

	// static Dbcontroller dbc4sql_queue_thread;

 

	/**
	 * static method
	 */
	@SuppressWarnings("unchecked")
	public void indexAll() {

		// ////ini
		if (indexBatchID == null)
			throw new RuntimeException("indexBatchID is null");

	//	dbc = new Dbcontroller();
	//	dbc.setAutoCommit(false);

		// ExecutorService executor = Executors.newSingleThreadExecutor();
		// 如果不需要特定的结果，则考虑使用下列形式的构造：Future<?> f = new
		// FutureTask<Object>(runnable, null)
		// ini_word_renva_event_bak(); //cb20

		// if(true)
		// return ;
		// executor.execute(future);
		// 在这里可以做别的任何事情

		// ba30 only sincin lib
		System.out.println(" c2a");

		// cb20   //cb21 to change mutile
		
		 
		Thread Thread_ini_fentsiController=god.newThread(new Runnable() {
			
			@Override
			public void run() {
				fulltxtControllor.ini_fentsiController();
				
			}
		},"Thread_ini_fentsiController");
 

		
		
		// if(indexNum>0)
		int indexnum_pro;
		List li = this.readDBx(indexNum);
		logger.info(" sincin lib reaead recs conut:"+li.size());
		//cb21
		try {
			Thread_ini_fentsiController.join();
		} catch (InterruptedException e1) {
			 
			e1.printStackTrace();
		}
		
		//cb21 
		
		///cb21
		indexnum_pro=indexNum-li.size();
		logger.info(" problem lib will index recs conut:"+indexnum_pro);
		this.lidb = li;
		this.from = "sincinlib";
		System.out.println(" c2b");

		// cbc get rec and fentsicyi
		// fentsiOr fentsiOrcb9=(fentsiOr) god.getThreadResult(futureTask);
		// this.renvaEventCca29 = (renvaEventC) god.getThreadResult
		// (futureTask_loadRevaEventController);
		

		// this.fentsiCca29 = fentsiOrcb9;
		// /start to skulk
		Thread tdcba = new Thread(new sql_queue_thread());
		tdcba.setPriority(Thread.MAX_PRIORITY);
		tdcba.setName("--thd sqlqueue processor ");
		tdcba.start();

		writeToIndex();

		System.out.println(" c2");

		// cb3 process problemlib
		List li_pro = readDB4pro(indexnum_pro);
		this.lidb = li_pro;
		this.from = "problemlib";
		writeToIndex();

		System.out.println("---f");
		es.shutdown();
		System.out.println("---fca29");

		try {
			es.awaitTermination(3, TimeUnit.HOURS);
			threadPoosIsComplete = true;
			logger.info("es.awaitTermination  finish");
		} catch (InterruptedException e) {

			e.printStackTrace();
			logger.info("es.awaitTermination err");
		}

		// db9 change to theread syaogo haosyeo bminsye
		// Thread td= new Thread(new Runnable() {
		// public void run() {
		//
		// dbc.commit();
		// System.out.println(Thread.currentThread().getName());
		//
		// }
		// });
		// td.setPriority(Thread.MAX_PRIORITY);
		// td.setName("--thd cb9 finally");
		// td.start();
		// LastDBC.commit();
		// LastDBC.close();

		// if(Sqlqueue.size()==0)
		// tdcba
		// dbc4sql_queue_thread.close();
		logger.info("--  commit db  last : Sqlqueue.size " + Sqlqueue.size());
		// dbc4sql_queue_thread.commit();
		logger.info(" commit last db");
		try {
			tdcba.join();
		} catch (InterruptedException e) {

			e.printStackTrace();
		}
		System.out.println("---finish");

	}

	private void ini_word_renva_event_bak() {
		FutureTask futureTask = new FutureTask(new Callable() {// 使用Callable接口作为构造参数
					public Object call() {

						// 真正的任务在这里执行，这里的返回值类型为String，可以为任意类型

						// ini wordLib need2s
						fentsiOr fentsiCca22 = new fentsiOr();
						fentsiCca22.iniFentsiWordlibFromdb();// haosi 2s
						return fentsiCca22;
					}
				});
		// 使用futureTask创建一个线程
		Thread Thread1 = new Thread(futureTask);
		Thread1.setName(" thread 4 load  FentsiWordlib");
		Thread1.setPriority(Thread.MAX_PRIORITY);
		Thread1.start();
		// 测试后台的计算线程是否完成，如果未完成则等待
		// if (!futureTask.isDone()) {

		// cbc
		FutureTask futureTask_loadRevaEventController = new FutureTask(
				new Callable() {// 使用Callable接口作为构造参数
					public Object call() {
						logger.info("--start ini renva envent db");
						renvaEventC rec = new renvaEventC();
						rec.iniTypeKeywordLibFromDB();
						logger.info("  rec.iniTypeKeywordLibFromDB(); ok");
						rec.iniEventKeywordlibFromdb();

						// ini wordlib in writeToIndex();
						// ini word_stopword not need
						// cb3 ini map_Renva4problem
						inimap4Renva(); // prob renva fenlei map 180ms
						return rec;
					}
				});
		Thread Thread_loadRevaNevent = new Thread(
				futureTask_loadRevaEventController);
		Thread_loadRevaNevent.setName(" Thread_loadRevaNevent");
		Thread_loadRevaNevent.setPriority(Thread.MIN_PRIORITY);
		Thread_loadRevaNevent.start();

		System.out.println("--other work");
		// need 300 ms about

		// renvaEventC rec = null;
		// System.out.println("--start ini renva envent db finish");

		// System.out.println(fentsiOrcb9);

	}

	/**
	 * onlye  for sincin
	 * @param rs
	 * @return
	 */
	public Map converToMap(ResultSet rs) {	Map mp = new HashMap<String, String>();
		try {
		
			if (rs.next()) {
				String txt = rs.getString("content");

				mp.put("id", rs.getString("id"));
				mp.put("userId", rs.getString("userId"));
				mp.put("moodid", rs.getString("mood"));
				//o1d
			String moodname=	sincinController.getMood_cn(rs.getString("mood"));
			 	mp.put("moodname", moodname);
			 	
				mp.put("content", txt);
				mp.put("from", "sc");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mp;
	}

	public Map converToMap4prblm(ResultSet rs) {
		Map mp = new HashMap<String, String>();
		try {

			if (rs.next()) {
				String txt = rs.getString("title");
				mp.put("id", rs.getString("id"));
				mp.put("userId", rs.getString("author"));
				mp.put("moodid", "7");
			 	mp.put("moodname", "纠结");
				mp.put("content", txt);
				mp.put("from", "pr");
				mp.put("renvaids", rs.getString("moodtype") );
			 
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mp;

	}
	/**
	 * only 4 sincin lib
	 * 
	 * @param limitInt
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List readDBx(int limitInt) {
		List<Map> li = new ArrayList<Map>();
		// beclseu db is utf8...so length 15=5g hezi
		// and m.id= 489433
		String sql = "	 SELECT 	m.id, 	m.userId, 	mood, 	moodInfo. NAME, 	m.content FROM 	mood m LEFT JOIN moodInfo ON m.mood = moodInfo.id WHERE 	char_length(content) > 5 AND visibility > 0 AND m.id > ( 		SELECT  	IF (max(mid) IS NULL, 0, max(mid)) 	FROM 		mood4fulllog   	WHERE 		   indexbatchid = '@indexbatchid' and rectype = 'sincinlib'   ) ORDER BY 	id LIMIT  "
				+ limitInt;
		sql = sql.replaceAll("@indexbatchid", indexBatchID);
		System.out.println(sql);
		logger.info(sql);
		Dbcontroller dbc=new DbNdsController();
		ResultSet rs = dbc.getrs(sql);
		int n = 0;
		try {
			while (rs.next()) {
				n++;
				if (n % 100 == 0)
					System.out.println(" readDBx:" + n);

				// 首先使用ISO-8859-1字符集将name解码为字节序列并将结果存储新的字节数组中。
				// 然后使用GB2312字符集解码指定的字节数组
				// name = new String(name.getBytes("ISO-8859-1"),"GB2312");

				// 输出结果
				String txt = rs.getString("content");
				Map mp = new HashMap<String, String>();
				mp.put("id", rs.getString("id"));
				mp.put("userId", rs.getString("userId"));
				mp.put("moodid", rs.getString("mood"));
				mp.put("moodname", rs.getString("name"));
				mp.put("content", txt);
				mp.put("from", "心情库");
				// m.id,m.userId,mood,moodInfo.name,m.content

				li.add(mp);
			}
		} catch (SQLException e) {
			e.printStackTrace();
			throw new RuntimeException(e);

		}
		dbc.close();
		return li;
	}

	public fentsiOr fentsiCca29;
	private String txtLine;

	/**
	 * for jekai li .trave li
	 */
	Dbcontroller LastDBC;
	protected String Cur_str;
	/**
	 * cb23
	 */
	protected String saveJindu_sql;

	/**
	 * for li
	 */
	public void writeToIndex() {
		@SuppressWarnings("unused")
		fileC0 fc = new fileC0();
		List<Map> li1 = lidb;
		int n = 0;
		for (Map mp : li1) {
			
			n++;
			if (n % 300 == 0)
			{
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					 
					e.printStackTrace();
				}
				System.out.println("--writeToIndex cb2:" + n);
			}

			String line = (String) mp.get("content");

			// ca 28
			// String txtFentsied = fentsiCca29.fentsiByDBwordlib(line);
			// cb20
			List<String> txtFentsied = fulltxtControllor.MMsegFentsicyi
					.fentsi(line);
			this.Cur_str = line;

			if (txtFentsied.size() == 0) // 可能标点符号..走chenlei empty le ..
			{
				continue;
			}

			// ThreadPoolExecutor tpe = (ThreadPoolExecutor) this.es;
			// while (true) {
			// int size = tpe.getQueue().size();
			// if (size < 1000) {
			// break;
			// } else {
			// System.out.println("--cb2.queu size:" + size);
			// try {
			// Thread.sleep(2000);
			// } catch (InterruptedException e) {
			//
			// e.printStackTrace();
			// }
			// }
			// }

			// if(LastDBC==null)
			// {
			// LastDBC= new DbNdsController();
			// LastDBC.setAutoCommit(false);
			// }

			// fulltxtCtrlMultiThrd impt = new fulltxtCtrlMultiThrd();
			// impt.curLine = mp;
			// impt.CurLIne_fentsi = txtFentsied;
			// impt.renvaEventCca28 = this.renvaEventCca29;
			// impt.from = this.from;
			// impt.map_Renva4problem = this.map_Renva4problem; // cb3
			// es.execute(impt);

			this.curLine = mp;
			this.CurLIne_fentsi = txtFentsied;
			this.renvaEventCca28 = this.renvaEventCca29;
			run();

			// writeToIndexSinglePerMessage(mp,txtFentsied);
			// if(n%5000==0)
			// {
			// System.out.println("--submit500");
			// Thread td= new Thread(new Runnable() {
			// public void run() {
			//
			// dbc.commit();
			// System.out.println(Thread.currentThread().getName());
			//
			// }
			// });
			// td.setPriority(Thread.MAX_PRIORITY);
			// td.setName("--thd cb9");
			// td.start();
			//				
			// }

		}

	}

	/**
	 * @author attilax 1466519819@qq.com
	 * @param mp
	 * @param curLIneFentsi_word_arr
	 */
	private void writeToIndexSinglePerMessage(Map mp,
			List<String> curLIneFentsi_word_arr) {

		// cb9
		// this.dbc=new DbNdsController();

		// //c28 e

		System.out.println("正在建立索引 : " + curLIneFentsi_word_arr + "");
		this.id = (String) mp.get("id");

		String[] txtFentsiedArray = curLIneFentsi_word_arr
				.toArray(new String[curLIneFentsi_word_arr.size()]);
		// pilyeo hteu zaozao set le .
		if (renvaEventCca28 == null)
			renvaEventCca28 = new renvaEventC();

		// get renva
		if (this.from.equals("problemlib")) {
			String renvaids = (String) mp.get("renvaids");

			//o17 recommed
		//	this.renvaList = renvaEventCca28.geneRenvaList4problemlib(
				//	renvaids, mp);
			// this.renvaAll = JSONArray.fromObject(renvaResult).toString();
			//o17  
			this.renvaList =renvaEventCca28.getRenvasByKWnDweiuNKW2(txtFentsiedArray,this.Cur_str);
		} else {

		//	renvaEventCca28.getTypeFromDB(txtFentsiedArray);
			List<Map> renvaResult = renvaEventCca28.TypeResult;
			renvaResult=renvaEventCca28.getRenvasByKWnDweiuNKW2(txtFentsiedArray,this.Cur_str);
			this.renvaList =renvaResult;
			// this.renva = getrenva(txtFentsied);

		}
		this.renvaAll = JSONArray.fromObject(this.renvaList).toString();

		// get event
		renvaEventC rc = renvaEventCca22;
		@SuppressWarnings("unused")
		// List liEvent = renvaEventCca28.getEventsFromDBlib(txtFentsiedArray,
		// this.renvaList,this.txtLine);
		// cb5 change
		List liEvent = renvaEventCca28.getEventsFromOneRenvaRelation(
				txtFentsiedArray, "", this.Cur_str);
		this.events_li = liEvent;
		this.eventAll = JSONArray.fromObject(liEvent).toString();
		this.liEvents = liEvent;

		// //cinsyv
		this.mid = (String) mp.get("id");
		if (this.mid.equals("23763"))
			System.out.println("a");
		String moodnamej = (String) mp.get("moodname");
		moodnamej = convetMoodName2cinsyv_habin(moodnamej);
		String[] mood_arr = moodnamej.split(",");
		for (String mood : mood_arr) {
			this.cinsyv = getcinsyv(mood);

			System.out.println("--cinsyv" + this.cinsyv);
			System.out.println("--event" + this.event);
			String cur_splitBySpace = listUtil.toString(
					curLIneFentsi_word_arr, " ");
			this.uid = (String) mp.get("userId");
			this.moodid = (String) mp.get("moodid");

			this.moodname = (String) mp.get("moodname");
			// this.curLinenum=i+1;
			// TOD debug no db
			writeToIndexSingle(cur_splitBySpace);
		}
		// okkk();

		// save jindu
		savejindu(this.mid, this.from);
		// this.dbc.close();

		try {
			if (1 == 2)
				Thread.sleep(1);
		} catch (InterruptedException e) {

			e.printStackTrace();
		}

	}

	static String mood4fullTable;

	
	/**
	 *  renva event sincin trave
	 */
	protected void writeToIndexSingle(String txtFentsied) {
		int n = 0;
		for (Map mp : this.renvaList) {
			for (Map mp_event : this.events_li) {
				String renva = (String) mp.get("name");

				// Map mpEvent = (Map) this.liEvents.get(n);
				Map mpEvent = mp_event;
				String eventx = (String) mpEvent.get("event");

				String mood4fullTable_now; // cb0
				if (mood4fullTable == null)
					mood4fullTable_now = "mood4full";
				else
					mood4fullTable_now = mood4fullTable;
				String sql = "	insert into "
						+ mood4fullTable_now
						+ "(mid,content,renva,"
						+ "event,cinsyv,renvaAll,eventAll,fromx,createAt)"
						+ "values(#{id}, #{content},@renva, @event,@cinsyv,@renvaAll,@eventAll,@from,now())";

				// sql=sql.replaceAll("#", this.id);
				sql = sql.replaceAll("#\\{id\\}", this.id);
				sql = sql
						.replaceAll("#\\{content\\}", "'" + txtFentsied + "'");
				String convetSqlStringFromatx = convetSqlStringFromat(this.renvaAll);
				sql = sql.replaceAll("@renvaAll", convetSqlStringFromatx);
				sql = sql.replaceAll("@eventAll",
						convetSqlStringFromat(this.eventAll));

				sql = sql.replaceAll("@renva", convetSqlStringFromat(renva));
				sql = sql.replaceAll("@event", convetSqlStringFromat(eventx));
				sql = sql.replaceAll("@cinsyv",
						convetSqlStringFromat(this.cinsyv));
				sql = sql
						.replaceAll("@from", convetSqlStringFromat(this.from));

				// System.out.println(sql);
				logger.info(sql);
				// return ds;
				try {
					Sqlqueue.put(sql);
				} catch (InterruptedException e) {

					e.printStackTrace();
					logger.info(god.getTrace(e));
				}
				n++;
			}
		}
	}

	static Logger logger = Logger.getLogger("fulltxt");
	public static callbackItfs callback;

	
	/**
	 * @param  isAddToSqlqueue  , indexBatchID
	 * @return saveJindu_sql
	 */
	protected void savejindu(String mid2, String rectype_cb23) {
		String sql = "	insert into mood4fulllog(mid,rectype,timex,indexBatchID)"
				+ "values(@mid,'@rectype',now(),'@indexBatchID')";
		sql = sql.replaceAll("@mid", mid2);
		sql = sql.replaceAll("@rectype", rectype_cb23);
		sql = sql.replaceAll("@indexBatchID", indexBatchID);
this.saveJindu_sql=sql;
		
// String sql="";
		// if (sqlC == null)
		// exportTopic sqlC = new exportTopic();
if(isAddToSqlqueue)
{
		try {
			Sqlqueue.put(sql);
		} catch (InterruptedException e) {
			logger.info(god.getTrace(e));
			e.printStackTrace();
		}
}
		logger.info(sql);

	}
	public	boolean isAddToSqlqueue=true;	 
	//@Override
	public void run() {
		writeToIndexSinglePerMessage(this.curLine, this.CurLIne_fentsi);

	}

	public class sql_queue_thread implements Runnable {
		ExecutorService thPool = Executors.newFixedThreadPool(25);
		 

		@Override
		public void run() {

			int n = 0;
			// Dbcontroller
			// dbc4sql_queue_thread.setAutoCommit(false);
			String str = null;
			ArrayList<String> li = new ArrayList<String>();
			while (true) {
				if (threadPoosIsComplete && Sqlqueue.size() == 0) {

					// logger.info("--sqlqueue thread commit db last: ");
					logger
							.info("--cbb14sqlqueue thread commit   last : Sqlqueue.size "
									+ Sqlqueue.size());
					logger
							.info("--cbb15 commit   last : li size "
									+ li.size());
					// dbc4sql_queue_thread.commit();

					// cbc
					thPool.shutdown();
					try {
						logger.info("--thPool start awaitTermination ");
						thPool.awaitTermination(1, TimeUnit.HOURS);

					} catch (InterruptedException e) {

						e.printStackTrace();
						logger.info("thPool.awaitTermination err");
					}

					// ///

					execSql(li);
					logger.info("--sqlqueue thread exit: ");
					break;
				}

				try {
					if (Sqlqueue.size() == 0) {
						Thread.sleep(10);
						continue;// cbb

					}
					str = Sqlqueue.take();
					//o17   str is sql
					try{
						if(callback!=null)
					callback.callMethod(str);
					}catch (Exception e) {
						 logger.debug(god.getTrace(e));
						 indexAllCls.logger.debug(god.getTrace(e));
					}
				} catch (InterruptedException e) {

					e.printStackTrace();
					String s = god.getTrace(e);
					logger
							.info("-------------sqlqueue thread:InterruptedException"
									+ s);
				}
				if (str == null)
					continue;

				logger.debug("cb91425 get sql from queue:" + str);
				n++;
				logger.debug("  cb01301:n is :" + n);
				// 判断所在服务器是否为多核，从而根据情况编写代码逻辑
				// dbc4sql_queue_thread.execCb2(str);
				li.add(str);
				if (n % 500 == 0) {
					final List<String> li2 = (List<String>) li.clone();
					//					
					Thread td = execSql_multiThread(li2);
					thPool.execute(td);

					// dbc4sql_queue_thread.commit();
					logger.info("--Sqlqueue size:" + Sqlqueue.size());
					logger.info("--cb01300: 2k comit");
					li = new ArrayList<String>();
				}

				// if(es.isShutdown() && es.isTerminated()){

				logger.debug("--cbb1501:threadPoosIsComplete "
						+ threadPoosIsComplete);
				logger.debug("--cbb1502:Sqlqueue.size() " + Sqlqueue.size());
				logger.debug("--cbb1503:li.size()() " + li.size());

				// Date end = new Date();
				// Long pastTime = end.getTime() - start.getTime();
				// if (pastTime > 5000) {
				// if (1 == 1)
				// System.out.println("ok");
				// }

			}

			logger.debug("--thd sqlqueue processor runting exit ");
			// try {
			// Thread.sleep(10);
			// } catch (InterruptedException e) {
			// e.printStackTrace();
			//
			// }

		}

		private Thread execSql_multiThread(final List<String> li2) {
			Thread td_commit = new Thread(new Runnable() {
				public void run() {
					execSql(li2);
				}
			});
			td_commit.setPriority(Thread.MAX_PRIORITY);
			td_commit.setName("--thd td_commit  ");
			// td_commit.start();
			return td_commit;

		}

		public void execSql(List<String> li) {
			Dbcontroller dbc = new DbNdsController();
			dbc.setAutoCommit(false);
			for (String sql : li) {
				dbc.addBatch(sql);
			}
			dbc.executeBatch();
			dbc.commit();
			dbc.close();
		}
	}

}
